﻿using Iworld.Backstage.Framework;
using Iworld.Backstage.Framework.AdministratorService;
using Iworld.Toolkit.Helper;
using Iworld.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Iworld.Backstage
{
     [View(Page.管理员组列表)]
    public partial class AdministratorGroupListPage : UserControl
    {
        public AdministratorGroupListPage()
        {
            InitializeComponent();
        }

        private void CreateGroup(object sender, RoutedEventArgs e)
        {
           CreateGroupWindow cwin = new CreateGroupWindow();
           cwin.Closed+=Closed;
           cwin.Show();
        }

        void Closed(object sender, EventArgs e)
        {
            CreateGroupWindow cw = sender as CreateGroupWindow;
            if(cw.DialogResult == true)
            {
                AdministratorGroupListViewModel v = this.DataContext as AdministratorGroupListViewModel;
                v.RefreshCommand.Execute(1);
            }
        }

        private void EditGroup(object sender, RoutedEventArgs e)
        {
            CreateGroupWindow ewin = new CreateGroupWindow(){ Info= XamlHelper.GetDataContext<AdministratorGroupExport>(sender)};
            ewin.Closed += Closed;
            ewin.Show();
        }
    }
}
